﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using AMG.DALProfile;

namespace AMG.Web
{
    public partial class read : AMG.Web.UI.Page.UserPage
    {
        public string amgcode = "";
        public string username = "";
        public string sex = "";
        public string company = "";
        public string position = "";
        public string crno = "";
        public string driverlisecen = "";
        public string phone = "";
        public string address = "";
        public string mail="";
        public string zipcode="";
        public string isbook="";
        public string carno="";
        public string roundno = "";
        public string R="";
        public string cars = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { 
                
            }
            R = Request.QueryString["r"];
            AMG.DALSQLServer.AMG_UserInfo us = new AMG.DALSQLServer.AMG_UserInfo();
            AMG.Model.AMG_UserInfo usinfo = us.GetModel(int.Parse(Request.QueryString["r"]));
            amgcode = usinfo.AMGCode;
            username = usinfo.UserName;
            if (usinfo.Sex == false)
            {
                sex = "男";
            }
            else 
            {
                sex = "女";
            }
            
            company = usinfo.Company;
            position = usinfo.Positison;
            crno = usinfo.CRNo;
            if (usinfo.DriverLisecen == false)
            {
                driverlisecen = "无";
            }
            else
            {
                driverlisecen = "有";
            }
            phone = usinfo.Phone;
            address = usinfo.Address;
            mail = usinfo.Mail;
            zipcode = usinfo.ZipCode;
            if (usinfo.IsBook == false)
            {
                isbook = "否";
            }
            else
            {
                isbook = "是";
                DataTable dt = DbHelper.ExecuteTable(CommandType.Text, "select case CarID when '1' then 'C63' when '2' then 'SLK55' when 3 then 'SL63' when 4 then 'S65' when 5 then 'CLS63' when 6 then 'G55' when 7 then 'ML63' end as Cars from AMG_Book where UserID=" + R + "", null);
                for (int i = 0; i <= dt.Rows.Count - 1; i++)
                {
                    cars += " " + dt.Rows[i][0].ToString() + " ";
                }
            }
            carno = usinfo.CarNo.ToString();
            roundno = usinfo.RoundNo.ToString();
            checktable(Request.QueryString["r"]);
            DataBind();
        }

        private void checktable(string id)
        {
            unsubmit.InnerHtml = "<table width=\"563\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=\"infotab\"> ";
            AMG.DALSQLServer.AMG_UserInfo us = new AMG.DALSQLServer.AMG_UserInfo();
            AMG.Model.AMG_UserInfo usinfo = us.GetModel(int.Parse (id));
            if (usinfo.UserName == null || usinfo.UserName == "")
            {
                unsubmit.InnerHtml += "<tr><td class=\"redcolor\"><p>客户姓名</p></td><td class=\"redcolor\">&nbsp;</td></tr>";
            }
            
            if (usinfo.Company == null || usinfo.Company == "")
            {
                unsubmit.InnerHtml += "<tr><td class=\"redcolor\"><p>公司名称</p></td><td class=\"redcolor\">&nbsp;</td></tr>";;
            }
            if (usinfo.Positison == null || usinfo.Positison == "")
            {
                unsubmit.InnerHtml += "<tr><td class=\"redcolor\"><p>职位</p></td><td class=\"redcolor\">&nbsp;</td></tr>";;
            }
            if (usinfo.CRNo == null || usinfo.CRNo == "")
            {
                unsubmit.InnerHtml += "<tr><td class=\"redcolor\"><p>身份证号</p></td><td class=\"redcolor\">&nbsp;</td></tr>";;
            }
            if (usinfo.Phone == null || usinfo.Phone == "")
            {
                unsubmit.InnerHtml += "<tr><td class=\"redcolor\"><p>电话号码</p></td><td class=\"redcolor\">&nbsp;</td></tr>";;
            }
            if (usinfo.Address == null || usinfo.Address == "")
            {
                unsubmit.InnerHtml += "<tr><td class=\"redcolor\"><p>邮寄地址</p></td><td class=\"redcolor\">&nbsp;</td></tr>";;
            }
            if (usinfo.ZipCode == null || usinfo.ZipCode == "")
            {
                unsubmit.InnerHtml += "<tr><td class=\"redcolor\"><p>邮政编码</p></td><td class=\"redcolor\">&nbsp;</td></tr>";;
            }
            if (usinfo.Mail == null || usinfo.Mail == "")
            {
                unsubmit.InnerHtml += "<tr><td class=\"redcolor\"><p>电子信箱</p></td><td class=\"redcolor\">&nbsp;</td></tr>";;
            }
            if (usinfo.RoundNo == null || usinfo.RoundNo == 0)
            {
                unsubmit.InnerHtml += "<tr><td class=\"redcolor\"><p>参加的轮次</p></td><td class=\"redcolor\">&nbsp;</td></tr>"; ;
            }
            unsubmit.InnerHtml += "<tr><td >&nbsp;</td></tr><tr><td >&nbsp;</td></tr></table>";
        }

        public string checknull(string str)
        {
            if (str == null || str == "")
            {
                return "*未填写";
            }
            else
            {
                return str;
            }
        }

        public string checknull1(string str)
        {
            if (str == null || str == "--")
            {
                return "*未填写";
            }
            else
            {
                return str;
            }
        }

        public string checknull2(string str)
        {
            if (str == null || str == "99")
            {
                return "*未填写";
            }
            else
            {
                return str;
            }
        }

        
    }
}
